package com.wpf.flux2client.controller;

import com.wpf.api.IPersonApi;
import com.wpf.flux2client.bean.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
public class PersonControllerClient {


    @Autowired
    private IPersonApi personApi;

    @GetMapping("/test")
    public void test(){
//        Flux<Person> all = this.personApi.getAll();
//        all.subscribe(System.out::println);
        this.personApi.queryPersonById("5bff91859da64f2d90a5b62b")
                .subscribe(person -> {
                   System.out.println(person);
                });
    }

    @GetMapping("/demo")
    public void demo(){

//        personApi.getAll();
//        personApi.deleteById("1111");
//        personApi.queryPersonById("2222");
        personApi.save(Mono.just(Person.builder().id("333").name("Tom").age(33).build())).subscribe(System.out::println);
    }

}
